﻿using System.Text;
using MHTools.Common;

namespace RemoteDesktop.Client.Data
{
    /// <summary>
    /// Defines config on the client side.
    /// </summary>
    public class ClientConfig : XmlSerializableObject<ClientConfig>
    {
        /// <summary>
        /// Gets or sets the HTTP prefix used to add before the message body.
        /// </summary>
        public string SendConnectionHttpPrefix;

        /// <summary>
        /// Gets or sets the HTTP prefix used to add before the message body.
        /// </summary>
        public string ReceiveConnectionHttpPrefix;

        /// <summary>
        /// Gets or sets address of the server.
        /// </summary>
        public string ServerAddress = "www.your-ip-here.com";

        /// <summary>
        /// Gets or sets port of the server.
        /// </summary>
        public int ServerPort = 80;

        /// <summary>
        /// Gets or sets port of the tunnel application.
        /// </summary>
        public int TunnelApplicationPort = 12345;

        /// <summary>
        /// Gets or sets maximum connection time in seconds.
        /// </summary>
        public double MaxConnectionTime = 3600;

        /// <summary>
        /// Gets or sets maximum packet size in KB.
        /// </summary>
        public double MaxPacketSize = 100;

        //**************************************************
        //
        // Constructors
        //
        //**************************************************

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public ClientConfig()
        {
            // create default http prefix for send connection
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("POST /post HTTP/1.1");
            builder.AppendFormat("Host: {0}{1}\r\n", this.ServerAddress, this.ServerPort == 80 ? string.Empty : ":" + this.ServerPort);
            builder.AppendLine("Content-Type: application/octet-stream");
            this.SendConnectionHttpPrefix = builder.ToString();

            // create default http prefix for receive connection
            builder = new StringBuilder();
            builder.AppendLine("GET /get HTTP/1.1");
            builder.AppendLine("Host: www.your-ip-here.com");
            builder.AppendLine("Content-Type: application/octet-stream");
            this.ReceiveConnectionHttpPrefix = builder.ToString();
        }

        #endregion

    }
}
